// 引入接口模块
import request from '@/utils/request'

// 获取编辑菜单信息接口
export const getEditMenuInfo = (id = -1) => {
  return request({
    method: 'get',
    url: '/boss/menu/getEditMenuInfo',
    // 这里使用params传值，也可以直接在url后面传值
    params: {
      id
    }
  })
}

// 保存、新增菜单
export const saveOrUpdate = (data) => {
  return request({
    method: 'post',
    url: '/boss/menu/saveOrUpdate',
    data
  })
}

// 获取所有菜单
export const getAll = () => {
  return request({
    method: 'get',
    url: '/boss/menu/getAll'
  })
}

// 删除菜单
export const deleteMenu = (id) => {
  return request({
    method: 'delete',
    url: `/boss/menu/${id}`
  })
}

// 获取所有菜单并按层级展示
export const getMenuNodeList = () => {
  return request({
    method: 'get',
    url: '/boss/menu/getMenuNodeList'
  })
}

// 给角色分配菜单
export const allocateRoleMenus = data => {
  return request({
    method: 'post',
    url: '/boss/menu/allocateRoleMenus',
    data
  })
}

// 获取角色拥有的菜单列表
export const getRoleMenus = roleId => {
  return request({
    method: 'get',
    url: `/boss/menu/getRoleMenus?roleId=${roleId}`
  })
}
